package com.wx.sign;

import java.io.ByteArrayOutputStream;
import java.util.zip.GZIPOutputStream;

public class GZipUtils {
    public static byte[] compress(byte[] data) {
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            // 压缩
            GZIPOutputStream gos = new GZIPOutputStream(baos);
            gos.write(data, 0, data.length);
            gos.finish();
            byte[] output = baos.toByteArray();
            baos.flush();
            baos.close();
            return output;
        } catch (Exception e) {
            return new byte[0];
        }
    }
}
